var time_message = "";
var wait_ajax = "";
var num = 0;
var canClick = true;
var layer13_car = document.querySelector(".layer13_car");
$(".readyGO").on("click", function() {
	//不允许用户反复点击
	if(canClick) {
		canClick = false;
		//等待ajax请求的数据返回,并模拟转动
		wait_ajax = setInterval(function() {
			num++;
			layer13_car.style.webkitTransform = "rotateZ(" + 20 + num * 7.2 + "deg)";
		}, 10);

		//手消失
		$(".hand").css("display", "none");

		$.ajax({
			type: "get",
			url: "rotate.php",
			async: true,
			success: function(data) {
				clearInterval(wait_ajax);
				num = 0;
				var deg = data;
				console.log(deg)
				$(".layer13_car").rotate({
					duration: 8000,
					//获取等待ajax时转动的度数
					angle: 20 + (num * 7.2) % 360,
					animateTo: 1800 + parseInt(deg),
					easing: $.easing.easeOutExpo
				});
				var prize_img = document.querySelector(".prize_img");
				time_message = setTimeout(function() {
					if(deg == 110) {
						alert("恭喜获得海洋温泉门票");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize1.png";
					} else if(deg == 155) {
						alert("恭喜获得神秘岛门票");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize2.png";
					} else if(deg == 200) {
						alert("恭喜获得梦幻剧场门票");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize3.png";
					} else if((deg == 245) || (deg == 65)) {
						alert("你获得了一份神秘的奖品");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize4.png";
					} else if(deg == 290) {
						alert("恭喜获得海泉湾吉祥公仔");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize5.png";
					} else if(deg == 335) {
						alert("恭喜获得明星海报");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize6.png";
					} else if(deg == 20) {
						alert("运气爆棚,赢得海景房一套");
						$(".layer14").css("display", "block");
						prize_img.src = "img/14/prize7.png";
					}
					canClick = true;
				}, 8000)

			}

		});

	}

})